#define _GNU_SOURCE
#include "App_Pool.h"
#include "log/log.h"
#include <unistd.h>

/* 测试进程池 */
static int task_fun(void *arg)
{
    char *msg = (char *)arg;
    log_debug("pool_fun (%d)执行,接受到的消息是%s", gettid(), msg);
    return 0;
}

int main(int argc, char const *argv[])
{

    // 1.初始化进程池
    App_Pool_Init(5);

    // 2.注册任务
    for (int i = 0; i < 10; i++)
    {
        char *msg = malloc(10);
        sprintf(msg, "hello world %d", i);
        App_Pool_RegisterTask(task_fun, msg);
    }
    sleep(1);
    // 3.结束进程池
    App_Pool_End();

    return 0;
}
